package com.acmedcare.framework.exchange.center.core.metadata;


import java.lang.reflect.Method;

public interface IDataConsumer<T> {

  default Class<?> getEntityClass() {
    Method[] methodArray = getClass().getDeclaredMethods();
    for (Method method : methodArray) {
      if ("receive".equals(method.getName())) {
        return method.getParameterTypes()[0];
      }
    }

    return null;
  }

  void receive(T data);

  default <K> K receiveAndPublish(T data) {

    receive(data);
    return null;
  }
}